<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // string   number   boolean   undefined

    // Number()    传入一个参数，将其转化为数字并返回    (将其他类型转化为数字)
    //var result = Number("100");
    //console.log(result);

    console.log(Number("100"));    //100
    console.log(Number("100a"));    //NaN

    console.log(Number(100));    //100

    console.log(Number(true));  // 1
    console.log(Number(false));  // 0
    console.log(Number(null));  // 0
    console.log(Number(undefined));  // NaN */


    // String()    传入一个参数，将其转化为字符串并返回     (将其他类型转化为字符串)
    console.log(String("100"));  //  "100"
    console.log(String("100a"));  //  "100a"

    console.log(String(100));  // "100"

    console.log(String(true));  // "true"
    console.log(String(false));  // "false"

    console.log(String(null));  //  "null"
    console.log(String(undefined));  //  "undefined"


    // Boolean()  传入一个参数,将其转化为布尔值并返回  (将其他类型转化为布尔值)

    // "" 0 NaN null undefined  => 转化为布尔值为false  

    console.log(Boolean("100"));  //  true
    console.log(Boolean("100a"));  //  true
    console.log(Boolean("a"));    //  true
    console.log(Boolean(" "));   // 空格字符串  true
    console.log(Boolean(""));    // 空字符串  false

    console.log(Boolean(100));  // true
    console.log(Boolean(-100));  //  true
    console.log(Boolean(0.5));  //  true
    console.log(Boolean(0));  //   false
    console.log(Boolean(NaN));  //   false
    console.log(Boolean(Infinity));  //   true

    console.log(Boolean(true));  // true
    console.log(Boolean(false));  // false

    console.log(Boolean(null));  //  false
    console.log(Boolean(undefined));  //  false


    var b = a++;['先把a的值赋值给b，a在自+1']

    var b = ++a;['a先自+1，再赋值给b']
</script>

</html>